import java.util.*;

public abstract class ObjectModel {
  protected PVector _size;
  protected PVector _pos;
  protected boolean _selected;
  protected BoundingBoxModel _boundingbox;
  protected int _state;
  protected boolean _canBeMoved;
  protected float _scale;

  public PVector getSize() {
    return this._size;
  }

  public PVector getPosition() {
    return this._pos;
  }

  public void setPosition(PVector p) {
    this._pos = p;
    this._boundingbox.setCornerTopLeft(new PVector(this._pos.x - (this._scale * (this._size.x/2.0)), this._pos.y - (this._scale * (this._size.y/2.0)), this._pos.z - (this._scale * (this._size.z/2.0))));
    this._boundingbox.setCornerBottomRight(new PVector(this._pos.x + (this._scale * (this._size.x/2.0)), this._pos.y + (this._scale * (this._size.y/2.0)), this._pos.z + (this._scale * (this._size.z/2.0))));
  }

  public boolean isSelected() {
    return this._selected;
  }

  public void setSelected(boolean state) {
    this._selected = state;
  }

  public BoundingBoxModel getBoundingBox() {
    return this._boundingbox;
  }

  public void setBoundingBox(PVector c, PVector c2) {
    this._boundingbox.setCornerTopLeft(c);
    this._boundingbox.setCornerBottomRight(c2);
  }

  public boolean isClicked(PVector p) {
    return this._boundingbox.inBoundingBox(p);
  }

  public void setState(int state) {
    this._state = state;
  }

  public int getState() {
    return this._state;
  }

  public boolean canBeMoved() {
    return this._canBeMoved;
  }

  public void updateBoundingBox() {
    this._boundingbox.setCornerTopLeft(new PVector(this._pos.x - (this._scale * (this._size.x/2.0)), this._pos.y - (this._scale * (this._size.y/2.0)), this._pos.z - (this._scale * (this._size.z/2.0))));
    this._boundingbox.setCornerBottomRight(new PVector(this._pos.x + (this._scale * (this._size.x/2.0)), this._pos.y + (this._scale * (this._size.y/2.0)), this._pos.z + (this._scale * (this._size.z/2.0))));
  }

  public abstract void draw();
  public abstract void update();
}

